// pages/xq/xq.js

Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    isfixed: true,
    isipt: true,
    isanniu: true,
    ipt: '',
    pinglun: []
  },

  //点击评论ipt
  pingshunbtn() {
    this.setData({
      isfixed: false,
      isipt: false,
      isanniu: false
    })
    // console.log(this.data.isanniu)
  },

  //遮罩层点击
  zzcclick() {
    this.setData({
      isfixed: true,
      isipt: true,
      isanniu: true
    })
  },

  //input输入时获取值
  iptfn(e) {
    this.setData({
      ipt: e.detail.value
    })
  },

  //点击发布
  fabuclick() {
    // console.log(this.data.ipt)
    // console.log(this.data.list)
    if (!this.data.ipt.trim()) {
      return
    }
    var obj = {
      uid: 1,
      content: this.data.ipt,
      bdid: this.data.list.id
    }
    wx.request({
      url: 'http://localhost:2345/dashboard/saveList',
      method: 'post',
      data: {
        bdid: obj.bdid,
        content: obj.content,
        uid: 1
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      success: (res) => {
        console.log(res);
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var app = getApp();
    var lists = app.list;
    this.setData({
      list: lists
    })
    let bdid = this.data.list.id;
    wx.request({
      url: 'http://localhost:2345/dashboard/getList',
      method: 'get',
      data: {
        bdid: bdid
      },
      success: (res) => {
        console.log(res)
        this.setData({
          pinglun : res.data.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})